package models;

import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;

import play.data.binding.As;
import play.data.validation.Required;
import siena.DateTime;
import siena.Filter;
import siena.Id;
import siena.Index;
import siena.Model;
import siena.Query;

public abstract class AbstractActivity extends Model {
	/** The activity id */
	@Id public Long id;
		
	/** The start date of the activity */
	@Index("start_index")
	@DateTime
	@As(value="yyyy/MM/dd HH:mm:ss") 
	@Required public Date start;
	
	/** The end date of the activity */
	@Index("end_index")
	@DateTime
	@As(value="yyyy/MM/dd HH:mm:ss") 
	@Required public Date end;
	
	/** The focus on its based the activity */
	@Index("focus_index")
	@Required public Focus focus;
	
	public Date created;
	
	public Date updated;
	@Override
	public void save() {
		if(this.id == null) this.created = new Date();
		else this.updated = new Date();
		// Preprocess dates
		/*List<Date> dates = new ArrayList<Date>();
		long interval = 1000 * 60 * 60; // 1 hour in millis
		long endTime = this.end.getTime(); // create your endtime here, possibly using Calendar or Date
		long curTime = this.start.ge tTime();
		while (curTime <= endTime) {
		  dates.add(new Date(curTime));
		  curTime += interval;
		}*/
		
		super.save();
	}
}
